package ControlLayer;
import ModelLayer.DVDCollections;
import ModelLayer.DVD;
import ModelLayer.Copy;
import java.util.ArrayList;
//model layer package has to be imported
/**
 * Controller class for the DVD collection
 * 
 * @author Gruppe A 
 * @version 1.0
 */
public class DVDCtr
{
    private DVDCollections dc;

    /**
     * Constructor for objects of class DVDCtr
     */
    public DVDCtr()
    {
        dc = DVDCollections.getInstance();

    }

    /**
     * A method for finding a dvd, it executes the command from our dvd container(DVDCollections)
     * @param long id
     * @return DVD dvd
     */
    //Dummy implementation: after implementing the model layer 
    //objects of class DVD are to be returned, not String
    public DVD findDVD(long id)
    {
        return dc.findDVD(id);

    }

    /**
     * A method for finding a copy, it first searches though the dvds using the id number provided, once found it then seaches the collections for the specific copy.
     * @param long id
     * @param long serialnr
     * @return Copy copy
     */
    public Copy findCopy(long id, long serialnr)
    {
        DVD d = findDVD(id);
        Copy c = d.findCopy(serialnr);
        return c;
    }

    /**
     * A method for creating an object of dvd, once this object has been created it adds it
     * to our dvd container(DVDCollections)
     * @param String title
     * @param String director
     * @param long id
     */
    //Dummy implementation: more parameters are probaly to added
    public void createDVD(String title, String director, long id)
    {       
        DVD d = new DVD(title, director, id);
        dc.addDVD(d);
    }

    /**
     * A method for deleting a dvd from our dvd container(DVDCollections)
     * it takes a long id as a parameter
     * @param long id
     */
    public void deleteDVD(long id)
    {
        DVD d = dc.findDVD(id);
        dc.removeDVD(d);
    }

    /**
     * A method for creating an object of copy, once this object has been
     * created it adds it to our copy container(CopyCollections)
     * @param long id
     * @param long serialnr
     * @param String aquiringDate
     * @double cost
     */
    public void createCopy(DVD d, long serialnr, String aquiringDate, double cost)
    {
        Copy c = new Copy(serialnr, aquiringDate, cost);
        d.addCopy(c);
    }

    /**
     * A method that lists all the dvds and their associated copies in an ArrayList.
     * @return ArrayList<DVD> listAllDVDs
     */
    public ArrayList listAllDvds()
    { 
        return dc.listAllDVDs();
    }

    /**
     * A method for updating existing dvds, it finds the specific dvd using it's id number and then executes the existing update command in our dvd container.
     * @param long idd
     * @param String title
     * @param String director
     * @param long id
     */
    public void updateDVD(long idd, String title, String director, long id)
    {
        DVD d = dc.findDVD(idd);
        dc.updateDVD(d, title, director, id);
    }

}
